package com.kun.config;

import com.kun.common.interceptor.JwtInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        List<String> list = new ArrayList<>();
        list.add("/user/toLogin");
        list.add("/user/register");
        list.add("/user/exportUsers");
        list.add("/user/importUsers");
        list.add("/webjars/**");
        list.add("/swagger-resources/**");
        list.add("/swagger-ui.html/**");
        list.add("/file/**");
        list.add("/eCharts/**");
        registry.addInterceptor(myJwtInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns(list);
    }

    @Bean
    public JwtInterceptor myJwtInterceptor(){
        return new JwtInterceptor();
    }


}
